package com.doyens.gmall.product.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doyens.gmall.model.product.BaseTrademark;
import com.doyens.gmall.product.mapper.BaseTrademarkMapper;
import com.doyens.gmall.product.service.BaseTrademarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Classname:BaseTrademarkServiceImpl
 * PackageName:com.doyens.gmall.product.service.impl
 *
 * @Author:uyijk
 * @Create:2023/7/26 15:13
 * @Version: 1.0
 */
@Service
public class BaseTrademarkServiceImpl implements BaseTrademarkService {

    @Autowired
    private BaseTrademarkMapper baseTrademarkMapper;

    @Override
    public IPage<BaseTrademark> getPage(Long page, Long size) {
        IPage<BaseTrademark> trademarkIPage = new Page<>(page,size);
        trademarkIPage = baseTrademarkMapper.selectPage(trademarkIPage, null);
        return trademarkIPage;
    }

    @Override
    public void save(BaseTrademark baseTrademark) {
        if(baseTrademark.getId()==null) {
            baseTrademarkMapper.insert(baseTrademark);
        }else{
            baseTrademarkMapper.updateById(baseTrademark);
        }
    }

    @Override
    public void deleteById(Long id) {
        baseTrademarkMapper.deleteById(id);
    }

    @Override
    public BaseTrademark getById(Long id) {
        return baseTrademarkMapper.selectById(id);
    }

    @Override
    public List<BaseTrademark> getTrademarkList() {
        return baseTrademarkMapper.selectList(null);
    }

    @Override
    public BaseTrademark getTrademarkByTmId(Long tmId) {
        return baseTrademarkMapper.selectById(tmId);
    }

}
